Iterating a function over a nested list of dataframes in python